package cn.com.dhcc.app.pub.core.consts;

import cn.com.dhcc.app.core.AppEnv.ParaGetTool;

/**
 * TLQ静态变量
 通用数据交换平台队列规划
发送队列规则: SQ_{SEND_NODE}_TO_{RECV_NODE}_{QUEUE_TYPE}
	{SEND_NODE}:发送节点代码
	{RECV_NODE}:接收节点代码
	{QUEUE_TYPE}：队列类型 >> 
							CM_DATA 				常规数据队列   
							CM_DATA_LOG 		常规数据监控队列
							SQL_DATA        		SQL数据队列
							SQL_DATA_LOG        SQL数据监控队列
							TEST        			测试队列
eg.
SQ_MWR_TO_TJ_CM_DATA
SQ_MWR_TO_TJ_CM_DATA_LOG
SQ_MWR_TO_TJ_SQL_DATA
SQ_MWR_TO_TJ_SQL_DATA_LOG
SQ_MWR_TO_TJ_TEST


接收队列规则: LQ_{QUEUE_TYPE}
eg.
LQ_CM_DATA
LQ_CM_DATA_LOG
LQ_SQL_DATA
LQ_SQL_DATA_LOG
LQ_TEST
 */
public class TlqConfig {
	
	/**
	 * tlq默认值
	 * 
	 * tlq.broker.supervise.port  tlq的管理连接端口 ，默认10252--tlq安装后就定好了
	 * tlq.broker.jms.port  tlq中QCU(也就是jmsbroker)的管理连接端口 默认11024--创建qcu时设置jndi后定好的
	 *###tlq.broker.dest.queue.conn.listen.port  目的接收队列的监听端口，发送队列对应的本地队列(接收队列的监听端口号)默认1888，这个端口号是接收方的接收进程的监听端口
	 * tlq.broker.queue.conn.listen.port  本节点的tlq的监听端口默认1888
	 * 
	 */
	
	/**
	 * 连接到TLQ的配置信息
	 */
	public static final String TLQ_BROKER_IP = ParaGetTool.getPara(String.class, "tlq.broker.ip");//TLQ安装IP
	public static final int TLQ_JMS_PORT = ParaGetTool.getPara(Integer.class, "tlq.broker.jms.port",11024);//TLQ JNDI端口，用于JMS收发消息，理论上跟QCU_TURBO_JMS_PORT一致
	public static final int TLQ_SUPERVISE_PORT = ParaGetTool.getPara(Integer.class, "tlq.broker.supervise.port",10252);//TLQ 监控管理端口 默认10252
	public static final int TLQ_QUEUE_CONN_LISTEN_PORT=ParaGetTool.getPara(Integer.class, "tlq.broker.queue.conn.listen.port",1888);
	public static final int TLQ_IS_DEBUG = ParaGetTool.getPara(Integer.class, "tlq.is.debug");//是否打印调试信息

	//
	
	//尝试连接qcu次数
	public static int DEGAULT_QCU_CONNECT_REPEAT_NUM = 20;
	/**
	 * 动态创建QCU的基本信息
	 */
	public static final String QCU_TURBO = "qcu_turbo";          //Turbo
	public static final int QCU_SEND_PROC_ID = 1;            //发送进程ID
	public static final String QCU_CONN_PRIFIX = "conn_";         //发送连接名称前缀，其规则为 conn_${sendQueueName}
	//public static final int QCU_TURBO_JMS_PORT = 11024;          //app连接到TLQ操作队列的端口
	//public static final int QCU_QUEUE_CONN_LISTEN_PORT = 1888;   //发送队列监控端口，发送队列到本地队列的链接端口号
	public static final String QCU_JNDI_CONNECTION_FACTORY = "TurboJNDIRemoteConnectionFactory";//自定义的JNDI远程连接工厂
	
	public static final String QCU_CLUSTER_JNDI_CONNECTION_FACTORY = "TurboJNDIClusterRemoteConnectionFactory";//自定义的集群JNDI远程连接工厂
	
	

	/**
	 * 本地队列
	 */
	public static final String LQ_CM_DATA = "LQ_CM_DATA";  						//本地队列，用于接收常规数据
	public static final String LQ_CM_DATA_LOG = "LQ_CM_DATA_LOG";  		//本地队列，用于接收常规数据路由状态数据
/*	public static final String LQ_SQL_DATA = "LQ_SQL_DATA";  					//本地队列，用于接收常规数据SQL数据
	public static final String LQ_SQL_DATA_LOG = "LQ_SQL_DATA_LOG";  	//本地队列，用于接收常规数据SQL数据路由状态数据*/
	public static final String LQ_TEST = "LQ_TEST";  							//本地队列，用于接收测试消息

	
	
	/**
	 * QCU默认参数
	 */
	public static class QCU{
		public static final int SEM_POOL_MAX_NUM = ParaGetTool.getPara(int.class, "tlq.qcu.sem_pool_max_num",100);
		public static final int QUE_SEND_BUFF = ParaGetTool.getPara(int.class, "tlq.qcu.que_send_buff",5000);
		public static final int QUE_RECV_BUFF = ParaGetTool.getPara(int.class, "tlq.qcu.que_recv_buff",5000);
		public static final int DY_LOCAL_QUE_MSG_NUM = ParaGetTool.getPara(int.class, "tlq.qcu.dy_local_que_msg_num",1000);
		public static final int DY_LOCAL_QUE_DATA_BUFF = ParaGetTool.getPara(int.class, "tlq.qcu.dy_local_que_data_buff",51200);
		public static final int DY_SEND_QUE_MSG_NUM = ParaGetTool.getPara(int.class, "tlq.qcu.dy_send_que_msg_num",1000);
		public static final int DY_SEND_QUE_SPACE_SIZE =  ParaGetTool.getPara(int.class, "tlq.qcu.dy_send_que_space_size",1024000);
		public static final int DY_SEND_QUE_DATA_BUFF = ParaGetTool.getPara(int.class, "tlq.qcu.dy_sendque_data_buff",51200);
		public static final int DY_LOCAL_QUE_SPACE_SIZE = ParaGetTool.getPara(int.class, "tlq.qcu.dy_local_que_space_size",1024000);
		public static final int EVENT_MSG_FLAG = ParaGetTool.getPara(int.class, "tlq.qcu.event_msg_flag",1);
		public static final int CONNID_MAX_NUM = ParaGetTool.getPara(int.class, "tlq.qcu.connid_max_num",100);//客户端连接最大数
		public static final int DUP_FILE_RENAME_FLAG = ParaGetTool.getPara(int.class, "tlq.qcu.dup_file_rename_flag",1);
		
		public static final int LQ_NUM = ParaGetTool.getPara(int.class, "tlq.qcu.lq.num",20);//qcu本地队列最大数量
		public static final int SQ_NUM = ParaGetTool.getPara(int.class, "tlq.qcu.sq.num",20);//qcu发送队列最大数量
	}
	
	/**
	 * 本地队列参数
	 *
	 */
	public static class LQ{
		public static final int MSG_NUM = ParaGetTool.getPara(int.class, "tlq.lq.msg_num",5);//存放的最大消息数
		public static final int MSG_SIZE = ParaGetTool.getPara(int.class, "tlq.lq.msg_size",10485760);//单个消息最大长度
		public static final int QUE_SPACE_SIZE = ParaGetTool.getPara(int.class, "tlq.lq.que_space_size", 51200);//队列中消息可用空间
		public static final int LOCAL_QUE_DATA_BUFF = ParaGetTool.getPara(int.class, "tlq.lq.local_que_data_buff",100);//非持久消息数据存储区大小
		public static final int MSG_ARRANGE_MODE = ParaGetTool.getPara(int.class, "tlq.lq.msg_arrange_mode",0);//组织模式
		public static final int USAGE_TYPE = ParaGetTool.getPara(int.class, "tlq.lq.usage_type",0);//使用类型
		public static final int DEF_PRIORITY = ParaGetTool.getPara(int.class, "tlq.lq.def_priority",0);//优先级
		public static final int DEF_PERSISTENCE = ParaGetTool.getPara(int.class, "tlq.lq.def_persistence",0);//持久性
		public static final String TRIG_TYPE = ParaGetTool.getPara(String.class, "tlq.lq.trig_type","None");//消息触发类型
		public static final int TRIG_PROG_ID = ParaGetTool.getPara(int.class, "tlq.lq.trig_prog_id",-1);//触发应用程序编号
		public static final int TRIG_AMOUNT = ParaGetTool.getPara(int.class, "tlq.lq.trig_amount",5);//触发消息个数
		public static final int DEAD_FLAG = ParaGetTool.getPara(int.class, "tlq.lq.dead_flag",0);//死信产生开关
	}
	
	
	/**
	 * 本地队列参数
	 *
	 */
	public static class SQ{
		public static final int MSG_NUM = ParaGetTool.getPara(int.class, "tlq.sq.msg_num",5);//存放最大的消息数
		public static final int MSG_SIZE = ParaGetTool.getPara(int.class, "tlq.sq.msg_size",10485760);//存放的单个消息最大长度
		public static final int QUE_SPACE_SIZE = ParaGetTool.getPara(int.class, "tlq.sq.que_space_size",51200);//队列中消息可用空间
		public static final int SENDQ_DATA_BUFF = ParaGetTool.getPara(int.class, "tlq.sq.sendq_data_buff",100);//非持久消息存储区大小
		public static final int DEF_PRIORITY = ParaGetTool.getPara(int.class, "tlq.sq.def_priority",4);//优先级
		public static final int DEF_PERSISTENCE = ParaGetTool.getPara(int.class, "tlq.sq.def_persistence",1);//持久性
		public static final int DEAD_FLAG = ParaGetTool.getPara(int.class, "tlq.sq.dead_flag",0);//死信产生开关
	}
	
	/**
	 * @todo 这个阈值应该是存储在规则库里面的
	 * TLQ监控指标阈值
	 */
	public static class TlqQuota{
		public static final int LOCAL_TLQ_DY_LQ_MSG_NUM = ParaGetTool.getPara(int.class, "tlq.sq.msg_num",5);
		public static final int LOCAL_TLQ_DY_SQ_MSG_NUM = ParaGetTool.getPara(int.class, "tlq.sq.msg_num",5);
		public static final int LOCAL_TLQ_DY_LQ_DATA_BUFF = ParaGetTool.getPara(int.class, "tlq.sq.msg_num",5);
		public static final int LOCAL_TLQ_DY_SQ_DATA_BUFF = ParaGetTool.getPara(int.class, "tlq.sq.msg_num",5);
	}

}
